part of 'updatable.dart';

class UpdatableMap<K, V> extends UpdatableState<Map<K, V>> with MapMixin<K, V> {
  UpdatableMap([Map<K, V> value = const {}]) : super(initValue: value);

  @override
  V? operator [](Object? key) {
    return _value[key as K];
  }

  @override
  void operator []=(K key, V value) {
    _value[key] = value;
    doUpdate();
  }

  @override
  void clear() {
    _value.clear();
    doUpdate();
  }

  @override
  int get length => _value.length;

  @override
  Iterable<K> get keys => _value.keys;

  @override
  V? remove(Object? key) {
    final val = _value.remove(key);
    doUpdate();
    return val;
  }
}
